跳转至正文

debian 12 快速安装 OpenMediaVault

更新于:  21:41

0.说在前面

以下操作仅在本地(中国)的网络环境进行过测试,外网请自行切换到对应的镜像服务器。

0.1 不吐不快

首先还是那句话,有条件的话,应该优先选择FreeNAS(现为TrueNAS)。在不得不这么做的时候(例如公网云并且无法安装NAS系统的情况下),才考虑OpenMediaVault。如果不得不安装OpenMediaVault的话,请继续阅读。

0.2 开始之前

在开始之前,请确保系统是干净的(是的,我说的就是阿里云之流会装一些私货的)。需要dd脚本的,请自行下载或使用我自己改写的dd脚本。

1. 开始安装之前

1.1 切换源

注意:如果是境外的服务器,请自行选择最近的镜像服务器

以下操作如无特殊说明,均默认为root账号操作。

目前(2024年02月18日)debian 12最好还是使用bullseye-security的源,设置脚本如下:

cat <<'EOF'> /etc/apt/sources.list
deb https://mirrors.ustc.edu.cn/debian/ bookworm main contrib non-free non-free-firmware
deb https://mirrors.ustc.edu.cn/debian/ bookworm-updates main contrib non-free non-free-firmware
deb https://mirrors.ustc.edu.cn/debian/ bookworm-proposed-updates main non-free non-free-firmware contrib
deb https://mirrors.ustc.edu.cn/debian/ bookworm-backports main non-free non-free-firmware contrib
deb-src https://mirrors.ustc.edu.cn/debian/ bookworm-updates main contrib non-free non-free-firmware
deb-src https://mirrors.ustc.edu.cn/debian/ bookworm main contrib non-free non-free-firmware
deb-src https://mirrors.ustc.edu.cn/debian/ bookworm-proposed-updates main contrib non-free non-free-firmware
deb-src https://mirrors.ustc.edu.cn/debian/ bookworm-backports main contrib non-free non-free-firmware
deb https://mirrors.ustc.edu.cn/debian-security bullseye-security main
EOF

更新系统

apt update -y
apt full-upgrade -y

1.2 切换到xanmod

官网:https://xanmod.org/

安装需要的程序

apt install -y wget gnupg

设置gpg公钥

wget -qO - https://dl.xanmod.org/archive.key | gpg --dearmor -o /usr/share/keyrings/xanmod-archive-keyring.gpg

添加源

echo 'deb [signed-by=/usr/share/keyrings/xanmod-archive-keyring.gpg] http://deb.xanmod.org releases main' | tee /etc/apt/sources.list.d/xanmod-release.list

更新源

apt update -y

要小心,如果装错了版本,会导致性能低下甚至无法正常启动。如果无法正常启动,也不要慌,在grub界面,选择《Advanced Options for Debian GNU/linux》,之后选择旧版本内核(不含recovery mode的那个选项)即可正常进入。

如果使用的是包含avx512特性的cpu的话,应该安装linux-xanmod-x64v4

查看cpu型号的命令:

cat /proc/cpuinfo

比如我用的工控机,执行上面的命令之后,返回如下信息:

processor       : 3
vendor_id : GenuineIntel
cpu family : 6
model : 42
model name : Intel(R) Core(TM) i3-2350M CPU @ 2.30GHz
stepping : 7
microcode : 0x2f
cpu MHz : 2108.951
cache size : 3072 KB
physical id : 0
siblings : 4
core id : 1
cpu cores : 2
apicid : 3
initial apicid : 3
fpu : yes
fpu_exception : yes
cpuid level : 13
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ht tm pbe syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic popcnt tsc_deadline_timer xsave avx lahf_lm epb pti ssbd ibrs ibpb stibp tpr_shadow flexpriority ept vpid xsaveopt dtherm arat pln pts vnmi md_clear flush_l1d
vmx flags : vnmi preemption_timer invvpid ept_x_only flexpriority tsc_offset vtpr mtf vapic ept vpid unrestricted_guest
bugs : cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass l1tf mds swapgs itlb_multihit mmio_unknown
bogomips : 4589.41
clflush size : 64
cache_alignment : 64
address sizes : 36 bits physical, 48 bits virtual

model name 就是当前设备的cpu的型号。flags 则是当前cpu支持的特性,如果在这里能看到avx512, 不用管型号写的什么,直接安装linux-xanmod-x64v4

我们在intel官网里面查到i3-2350M对应的产品序列为SandyBridge

然后到xanmod的官网搜索sandy,可以知道对应的版本是linux-xanmod-x64v2

因此,我们执行这个命令安装对应的内核版本:

apt install linux-xanmod-x64v2

安装其他需要的程序

apt install -y intel-microcode iucode-tool git git-lfs lrzsz gnutls-bin aria2 rsyslog

安装完毕后,输入reboot重启系统。

1.3 卸载原版内核(可选)

这个操作并不是必须的,原版内核可以确保在xanmod内核翻车的时候可以正常进入到系统。如果不是磁盘存储不足(系统分区)的情况下,不建议卸载原版内核。

查看当前的内核:

dpkg --get-selections | grep linux

应该会返回类似下面的结果

binutils-x86-64-linux-gnu                       install
firmware-linux-free install
libselinux1:amd64 install
libselinux1-dev:amd64 install
linux-base install
linux-headers-6.6.16-x64v2-xanmod1 install
linux-image-6.1.0-17-amd64 install
linux-image-6.1.0-18-amd64 install
linux-image-6.6.16-x64v2-xanmod1 install
linux-image-amd64 install
linux-libc-dev:amd64 install
linux-xanmod-x64v2 install
util-linux install
util-linux-extra install

移除普通内核

apt autoremove --purge linux-image-6.1.0-17-amd64 linux-image-6.1.0-18-amd64

2. 安装OpenMediaVault

注意:国内有可能会需要网络加速

安装OMV的公钥

wget --quiet --output-document=- https://packages.openmediavault.org/public/archive.key | gpg --dearmor --yes --output "/usr/share/keyrings/openmediavault-archive-keyring.gpg"

添加源

cat <<EOF >> /etc/apt/sources.list.d/openmediavault.list
deb [signed-by=/usr/share/keyrings/openmediavault-archive-keyring.gpg] https://packages.openmediavault.org/public sandworm main
# deb [signed-by=/usr/share/keyrings/openmediavault-archive-keyring.gpg] https://downloads.sourceforge.net/project/openmediavault/packages sandworm main
## Uncomment the following line to add software from the proposed repository.
# deb [signed-by=/usr/share/keyrings/openmediavault-archive-keyring.gpg] https://packages.openmediavault.org/public sandworm-proposed main
# deb [signed-by=/usr/share/keyrings/openmediavault-archive-keyring.gpg] https://downloads.sourceforge.net/project/openmediavault/packages sandworm-proposed main
## This software is not part of OpenMediaVault, but is offered by third-party
## developers as a service to OpenMediaVault users.
# deb [signed-by=/usr/share/keyrings/openmediavault-archive-keyring.gpg] https://packages.openmediavault.org/public sandworm partner
# deb [signed-by=/usr/share/keyrings/openmediavault-archive-keyring.gpg] https://downloads.sourceforge.net/project/openmediavault/packages sandworm partner
EOF

安装omv

export DEBIAN_FRONTEND=noninteractive
export APT_LISTCHANGES_FRONTEND=none
apt update -y
apt -y --auto-remove --show-upgraded \
--allow-downgrades --allow-change-held-packages \
--no-install-recommends \
--option DPkg::Options::="--force-confdef" \
--option DPkg::Options::="--force-confold" \
install openmediavault

执行如下命令初始化数据库

omv-confdbadm populate

执行如下代码,重新配置网络

omv-salt deploy run systemd-networkd

输入如下指令查看ip配置

ifconfig

应该会返回类似如下内容

​​ens18: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
inet 172.16.0.97 netmask 255.255.255.0 broadcast 172.16.0.255
ether bc:24:11:27:c6:4f txqueuelen 1000 (Ethernet)
RX packets 1834 bytes 1228323 (1.1 MiB)
RX errors 0 dropped 7 overruns 0 frame 0
TX packets 1942 bytes 342606 (334.5 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

如果有多个网卡,可能会看到多个ens或者eth的内容。其中inet的内容就是当前设备的ip地址。

于是打开浏览器,输入 http://172.16.0.97,即可访问nas的管理界面。

默认的账号和密码为

账号:admin
密码:openmediavault

到此,配置就全部完成了。enjoy(笑